package cn.quevo.beetl;

import java.util.Locale;

import org.beetl.ext.spring.BeetlSpringView;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.AbstractUrlBasedView;

/**
 * 重写beetl Spring视图
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2018-03-09 16:35:51
 * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
 * @return
 */
public class BeetlSpringViewResolver extends org.beetl.ext.spring.BeetlSpringViewResolver {

    public BeetlSpringViewResolver() {
        super();
    }

    /**
     * 实例化GroupTemplate
     */
    @Override
    protected AbstractUrlBasedView buildView(String viewName) throws Exception {
        // 获取config配置的后缀名
        //viewName = (StringUtils.isBlank(super.getPrefix())?"":super.getPrefix())+viewName;
        BeetlSpringView beetlView = (BeetlSpringView) super.buildView(viewName);
        beetlView.setBeanName("beetlView");
        // 为视图对象注入GroupTemplate
        beetlView.setGroupTemplate(super.getConfig().getGroupTemplate());
        return beetlView;
    }

    @Override
    public View resolveViewName(String viewName, Locale locale) throws Exception {
        return super.resolveViewName(viewName, locale);
    }
}
